Tomcat 7最大并发连接数的正确修改方法

您所在的位置:网站首页 tomcat websocket连接数 Tomcat 7最大并发连接数的正确修改方法

Tomcat 7最大并发连接数的正确修改方法

2024-06-03 13:19:08| 来源: 网络整理| 查看: 265

这是个很简单的问题,但是搜了一圈,发现大家都写错了。所以这里总结一下:

几乎所有的中文网页都介绍,要修改Tomcat的默认最大并发连接数,应该进行如下设置(实际上这些步骤是错误的):

--------------------------------------------

在tomcat配置文件server.xml中的配置中,和连接数相关的参数有:    minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10 maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75 acceptCount:允许的最大连接数,应大于等于maxProcessors,默认值为100 enableLookups:是否反查域名,取值为:true或false。为了提高处理能力,应设置为false connectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。 其中和最大连接数相关的参数为maxProcessors和acceptCount。如果要加大并发连接数,应同时加大这两个参数。 web server允许的最大连接数还受制于操作系统的内核参数设置,通常Windows是2000个左右,Linux是1000个左右。Unix中如何设置这些参数,请参阅Unix常用监控和管理命令 具体的配置信息: Java代码

--------------------------------------------

但是我仔细查了一圈,发现这个说法只是以讹传讹,并不适用于Tomcat 5.5以上的版本。这里先教大家怎么去查Tomcat的官网:

首先,在这里:http://tomcat.apache.org/ 我们点击左侧导航栏中“Documentation”下的Tomcat 7.0,进入到这个链接中:http://tomcat.apache.org/tomcat-7.0-doc/index.html ,详细的信息我们不用都看,在左侧导航栏中有一个链接Configuration,我们点进去之后,再点击其左侧导航栏中connector一项的HTTP,就进入到HTTP连接数及其他相关属性的设置页面了。在这里(http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)我们可以看到,在Connector的属性配置中,压根就没有maxProcessors等的设置选项。其中这句话已经介绍得很清楚:

If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the maxThreads attribute). If still more simultaneous requests are received, they are stacked up inside the server socket created by the Connector, up to the configured maximum (the value of the acceptCount attribute).

所以我们需要设置的是maxThreads和acceptCount这两个值:

其中,maxThreads的介绍如下:

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

而acceptCount的介绍为:

The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.

所以两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads:

今天就记录这么多,希望大家以后在转载别人的经验时更用心些,不要老出现上面那些以讹传讹的情况。也希望能对有些朋友起到帮助。



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭